import { Card, Descriptions } from 'antd'
import 'moment/locale/zh-cn'
import { observer } from 'mobx-react-lite'
import { useStore} from '@/store'
import {useState, useEffect} from 'react'


const ProfileLayout = () => {
  const {userStore} = useStore()
  const [profile, setProfile] = useState([])

  useEffect(() => {
    const fn = async ()=>{
      await userStore.getUserInfo()
      setProfile(userStore.userInfo)
    }
    fn()
  }, [userStore])
  if(profile.role === "STUDENT"){
    return (
      <div>
        <Card>
          <Descriptions title="个人信息" bordered column={2}>
            <Descriptions.Item label="学号">{profile.student_no}</Descriptions.Item>
            <Descriptions.Item label="姓名">{profile.name}</Descriptions.Item>
            <Descriptions.Item label="出生日期">{profile.birthday}</Descriptions.Item>
            <Descriptions.Item label="性别">{profile.gender}</Descriptions.Item>
            <Descriptions.Item label="学院">{profile.college_name}</Descriptions.Item>
            <Descriptions.Item label="专业">{profile.specialty_name}</Descriptions.Item>
            <Descriptions.Item label="邮箱" span={2}>{profile.email}</Descriptions.Item>
            <Descriptions.Item label="创建时间">{profile.create_time}</Descriptions.Item>
            <Descriptions.Item label="更新时间">{profile.update_time}</Descriptions.Item>
          </Descriptions>
        </Card>
      </div>
    )
    }else if(profile.role === "TEACHER"){
      return (
        <div>
          <Card>
            <Descriptions title="个人信息" bordered column={2}>
              <Descriptions.Item label="工号">{profile.teacher_no}</Descriptions.Item>
              <Descriptions.Item label="姓名">{profile.name}</Descriptions.Item>
              <Descriptions.Item label="出生日期">{profile.birthday}</Descriptions.Item>
              <Descriptions.Item label="性别">{profile.gender}</Descriptions.Item>
              <Descriptions.Item label="学院" span={2}>{profile.college_name}</Descriptions.Item>
              <Descriptions.Item label="邮箱" span={2}>{profile.email}</Descriptions.Item>
              <Descriptions.Item label="创建时间">{profile.create_time}</Descriptions.Item>
              <Descriptions.Item label="更新时间">{profile.update_time}</Descriptions.Item>
            </Descriptions>
          </Card>
        </div>
      )
  }else{
    return (
      <div>
        <Card>
          <Descriptions title="个人信息" bordered column={2}>
            <Descriptions.Item label="账号">{profile.account}</Descriptions.Item>
            <Descriptions.Item label="姓名">{profile.name}</Descriptions.Item>
            <Descriptions.Item label="邮箱" span={2}>{profile.email}</Descriptions.Item>
            <Descriptions.Item label="创建时间">{profile.create_time}</Descriptions.Item>
            <Descriptions.Item label="更新时间">{profile.update_time}</Descriptions.Item>
          </Descriptions>
        </Card>
      </div>
    )
  }
}

export default observer(ProfileLayout)